#!/bin/bash

echo "检查Python安装..."

if ! command -v python3 &> /dev/null; then
    echo "Python未安装，正在安装Python..."
    
    # 检测包管理器
    if command -v apt-get &> /dev/null; then
        # Debian/Ubuntu
        sudo apt-get update
        sudo apt-get install -y python3.8 python3-pip
    elif command -v yum &> /dev/null; then
        # CentOS/RHEL
        sudo yum install -y python38 python38-pip
    elif command -v dnf &> /dev/null; then
        # Fedora
        sudo dnf install -y python38 python38-pip
    else
        echo "未检测到支持的包管理器，请手动安装Python 3.8"
        exit 1
    fi
else
    echo "Python已安装"
fi

echo "检查jxlang是否已安装..."
if ! python3 -c "import jxlang" &> /dev/null; then
    echo "jxlang未安装，正在安装..."
    pip3 install jxlang -i https://pypi.tuna.tsinghua.edu.cn/simple
else
    echo "jxlang已安装,下次启动时请在终端输入jxlang即可启动"
fi